﻿using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Model.RF.TestRecord;
using IDAL.RF.TestRecord;

namespace DAL.RF.TestRecord
{
    public class TestItem_Record:BaseRepository<TestItem_RecordInfo>,ITestItem_Record
    {
        #region 静态字段部分
        private const string PARM_ID = "@ID";
        private const string PARM_PRODUCTSN = "@ProductSN";
        private const string PARM_RECORDTIME = "@RecordTime";
        private const string PARM_TESTITEMNAME = "@TestItemName";
        private const string PARM_TESTITEMDESC = "@TestItemDesc";
        private const string PARM_SPEC = "@Spec";
        private const string PARM_RESVALUE = "@ResValue";
        private const string PARM_RESULT = "@Result";
        #endregion

        #region 检索部分
        public IList<TestItem_RecordInfo> LoadEntities()
        {
            return null;
        }

        public TestItem_RecordInfo LoadEntity<T1>(T1 id)
        {
            return null;
        }

        public IList<TestItem_RecordInfo> TestItem_Record_GetbyID(int id)
        {
            SqlParameter parm = GetParameter();
            parm.Value = id;
            return ExcuteSqlToGetEntities("TestItem_Record_selectbyID", parm);
        }
        #endregion

        #region 参数部分
        #endregion

        #region 重新基类部分
        public override TestItem_RecordInfo GetEntityRecord(SqlDataReader rdr)
        {
            TestItem_RecordInfo pro = new TestItem_RecordInfo
            {
                ID = rdr.GetInt32(0),
                ProductSN = rdr.GetValue(1).ToString(),
                RecordTime = rdr.GetDateTime(2),
                TestItemName = rdr.GetValue(3).ToString(),
                TestItemDesc = rdr.GetValue(4).ToString(),
                Spec = rdr.GetValue(5).ToString(),
                ResValue = rdr.GetValue(6).ToString(),
                Result = rdr.GetBoolean(7)
            };
            return pro;
        }

        public override string GetInsertsp()
        {
            return "tb_TestItem_Record_Insert";
        }

        public override string GetUpdatesp()
        {
            return base.GetUpdatesp();
        }

        public override string GetDeletesp()
        {
            return base.GetDeletesp();
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_ID, SqlDbType.Int, 4);
            return Parm;
        }
        #endregion

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_ID, SqlDbType.Int, 4),
					new SqlParameter(PARM_PRODUCTSN, SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_RECORDTIME, SqlDbType.DateTime , 8),
					new SqlParameter(PARM_TESTITEMNAME, SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_TESTITEMDESC,SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_SPEC,SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_RESVALUE, SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_RESULT,SqlDbType.Bit, 1)
                };
            return parms;
        }

        public override void SetParameters(TestItem_RecordInfo tri, params SqlParameter[] Parms)
        {
            Parms[0].Value = tri.ID;
            Parms[1].Value = tri.ProductSN;
            Parms[2].Value = tri.RecordTime;
            Parms[3].Value = tri.TestItemName;
            Parms[4].Value = tri.TestItemDesc;
            Parms[5].Value = tri.Spec;
            Parms[6].Value = tri.ResValue;
            Parms[7].Value = tri.Result;
        }
    }
}
